"""Refactor ProductDetail model - remove fields moved to extended tables

Revision ID: 1eda163dc581
Revises: a289be90b234
Create Date: 2025-10-05 12:41:26.767416

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql

# revision identifiers, used by Alembic.
revision: str = '1eda163dc581'
down_revision: Union[str, Sequence[str], None] = 'a289be90b234'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    """Upgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('product_details', sa.Column('title', sa.String(length=200), nullable=True, comment='商品详情标题'))
    op.add_column('product_details', sa.Column('features', sa.Text(), nullable=True, comment='商品特点介绍'))
    op.add_column('product_details', sa.Column('meta_title', sa.String(length=200), nullable=True, comment='SEO标题'))
    op.add_column('product_details', sa.Column('meta_description', sa.String(length=500), nullable=True, comment='SEO描述'))
    op.add_column('product_details', sa.Column('meta_keywords', sa.String(length=500), nullable=True, comment='SEO关键词'))
    op.add_column('product_details', sa.Column('is_active', sa.Integer(), nullable=True, comment='是否激活：1-激活，0-禁用'))
    op.add_column('product_details', sa.Column('sort_order', sa.Integer(), nullable=True, comment='排序顺序'))
    op.drop_column('product_details', 'height')
    op.drop_column('product_details', 'after_sales')
    op.drop_column('product_details', 'specifications')
    op.drop_column('product_details', 'package_contents')
    op.drop_column('product_details', 'length')
    op.drop_column('product_details', 'attributes')
    op.drop_column('product_details', 'width')
    op.drop_column('product_details', 'weight')
    op.drop_column('product_details', 'warranty')
    op.drop_column('product_details', 'return_policy')
    op.drop_column('product_details', 'package_type')
    op.drop_column('product_details', 'images')
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('product_details', sa.Column('images', mysql.JSON(), nullable=True, comment='商品图片集（JSON数组）'))
    op.add_column('product_details', sa.Column('package_type', mysql.VARCHAR(collation='utf8mb4_unicode_ci', length=100), nullable=True, comment='包装类型'))
    op.add_column('product_details', sa.Column('return_policy', mysql.TEXT(collation='utf8mb4_unicode_ci'), nullable=True, comment='退换货政策'))
    op.add_column('product_details', sa.Column('warranty', mysql.VARCHAR(collation='utf8mb4_unicode_ci', length=200), nullable=True, comment='保修期限'))
    op.add_column('product_details', sa.Column('weight', mysql.DECIMAL(precision=8, scale=2), nullable=True, comment='重量（kg）'))
    op.add_column('product_details', sa.Column('width', mysql.DECIMAL(precision=8, scale=2), nullable=True, comment='宽度（cm）'))
    op.add_column('product_details', sa.Column('attributes', mysql.JSON(), nullable=True, comment='商品属性（颜色、尺寸等，JSON格式）'))
    op.add_column('product_details', sa.Column('length', mysql.DECIMAL(precision=8, scale=2), nullable=True, comment='长度（cm）'))
    op.add_column('product_details', sa.Column('package_contents', mysql.TEXT(collation='utf8mb4_unicode_ci'), nullable=True, comment='包装清单'))
    op.add_column('product_details', sa.Column('specifications', mysql.JSON(), nullable=True, comment='商品规格参数（JSON格式）'))
    op.add_column('product_details', sa.Column('after_sales', mysql.TEXT(collation='utf8mb4_unicode_ci'), nullable=True, comment='售后服务说明'))
    op.add_column('product_details', sa.Column('height', mysql.DECIMAL(precision=8, scale=2), nullable=True, comment='高度（cm）'))
    op.drop_column('product_details', 'sort_order')
    op.drop_column('product_details', 'is_active')
    op.drop_column('product_details', 'meta_keywords')
    op.drop_column('product_details', 'meta_description')
    op.drop_column('product_details', 'meta_title')
    op.drop_column('product_details', 'features')
    op.drop_column('product_details', 'title')
    # ### end Alembic commands ###
